<?php

$email = $_POST["email"];
$password = $_POST["password"];


include("conexao.php");
$sql = "select * from adms where adm_email = '$email' and adm_password = '$password';" ;
$rs = mysql_query($sql,$connection) or die ("A consulta falhou, porque é uma fracassada. ".mysql_error()); /* Executa a Query */

$num = mysql_num_rows($rs);
if ($num == 1) {

session_start();
$linha = mysql_fetch_array($rs);
$_SESSION["admnome"] = $linha["adm_name"];

header("Location:admhome.php") ;

}

else{

$sql = "select * from users where user_email = '$email' and user_password = '$password';";
$rs2 = mysql_query($sql,$connection) or die ("A consulta falhou, porque é uma fracassada. ".mysql_error()); /* Executa a Query */

$num2 = mysql_num_rows($rs2);

if ($num2 == 1) {
session_start();
$linha = mysql_fetch_array($rs2);
$_SESSION["username"] = $linha["user_firstname"];
$_SESSION["usercode"] = $linha["user_code"];



header("Location:userhome.php");

}


else {

header("Location:indexwrong.php");


}




}



?>
